/* Author: Nahuel F. Lema, Maxi Yañez

 */

var contactoController = {

    validate: {

	get: function(){
	    var componentsPath = scriptsController.defs.baseUrl + scriptsController.defs.componentsPath + 'jvalidation/',
	    self = this;

	    $.getScript(componentsPath + 'jquery.validate.min.1.9.js', function(){
		self.bind();
	    });
	},

	bind: function(){
	    var form = $(js.get.item('#form-container')[0]);

	    $(js.get.item('#submit-form-contacto')[0]).click(function(e){
		e.preventDefault();
		form.submit();
	    });
	    
	    form.validate({
		rules: {
		    'nombre' : {
			required : true,
			minlength: 10
		    },
		    'email': {
			required : true,
			email	 : true
		    },
		    'consulta' : {
			required : true,
			minlength: 10
		    }
		},
		messages: {
		    'nombre' : {
			required : "Este campo es requerido",
			minlength: "Ingrese un minimo de 10 caracteres"
		    },
		    'email': {
			required : "Este campo es requerido",
			email	 : "Ingrese un email valido"
		    },
		    'consulta' : {
			required : "Este campo es requerido",
			minlength: "Ingrese un minimo de 10 caracteres"
		    }
		},
		submitHandler: function($form) {
		    scriptsController.fixedLoader.show();
                    $form.submit();
		}
	    });
	},

	init: function(){
	    this.get();
	}
    },

    init: function(){
	this.validate.init();
    }
}

contactoController.init();